(function(){
	Ext.onReady(function(){
		
		//一对多的关系 
		Ext.define("User",{
			extend:'Ext.data.Model',
			fields:[
				{name:'userId',type:'string'},
				{name:'name',type:"string"}
			],
			hasMany:{model:'Order',name:'orders'}  //has many
		});
		
		Ext.define("Order",{
			extend:'Ext.data.Model',
			fields:[
				{name:'orderId',type:'string'},
				{name:'name',type:"string"}
			],
			belongsTo:'User' //belongsTo
		});
		
		var mproxy = Ext.create("Ext.data.proxy.Ajax",{
			model:'User',
			url:'user.json',
			reader:{
				type:'json',
				root:'users'
			}
		});
		
		mproxy.doRequest(new Ext.data.Operation({
			action:'read'
		}),function(item){
			alert(item.response.responseText);
			var user = item.resultSet.records[0];
			var orders = user.orders();
			orders.each(function(order){
				alert(order.get('name'));
			});
		});
	});
})();